from django.contrib import admin

# Register your models here.
from mine.models import Order, Cart, Comments


@admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
    """订单后台管理"""
    list_display = ('sn', 'user', 'to_user', 'to_area', 'to_phone',
                    'remark', 'express_type', 'express_no', 'status')
    # 按照用户名和昵称搜索，搜索条件()
    search_fields = ('user__username', 'user__nickname', 'to_user')
    # # 修改分页数据的大小
    list_per_page = 5
    # # 设置过滤器
    list_filter = ('status',)
    # # 方式2：设置字段为不可编辑，但可以显示
    # readonly_fields = ['sn']


@admin.register(Cart)
class CartAdmin(admin.ModelAdmin):
    """购物车后台管理"""
    list_display = ('user', 'name',
                      'price', 'img', 'status')

    list_per_page = 5
    list_filter = ('status', )

@admin.register(Comments)
class CommentsAdmin(admin.ModelAdmin):
    """评论管理"""
    list_display = ('user', 'product', 'order', 'desc',
    'score', 'is_valid', 'img_list')
    list_per_page = 5
    list_filter = ('is_valid',)
